package com.fairytask.tools
{
	import com.greensock.loading.LoaderMax;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import flash.system.Security;
	import flash.system.SecurityDomain;

	public class CommonTools
	{
		public function CommonTools()
		{
		}
		
		public static function get context():LoaderContext
		{
			var context:LoaderContext=new LoaderContext();
			if (Security.sandboxType == Security.REMOTE)
			{
				context.securityDomain=SecurityDomain.currentDomain;
			}
			context.applicationDomain=ApplicationDomain.currentDomain;
			return context;
		}
		
		public static function getMcByName(pMax:LoaderMax,pName:String,pClass:String,pParent:Sprite=null):MovieClip
		{
			//com.fairytask.ui.roomMc
			var tmpClass	:Class	=	pMax.getLoader(pName).getClass(pClass);
			var tmpMc:MovieClip	=	new tmpClass() as MovieClip;
			if(null!=pParent)
			{
				pParent.addChild(tmpMc);
			}
			return tmpMc;
		}
	}
}